package com.ruoyi.lclook.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.lclook.domain.LcBanner;
import com.ruoyi.lclook.service.ILcBannerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 海报Controller
 * 
 * @author Choi
 * @date 2021-08-07
 */
@RestController
@RequestMapping("/lclook/banner")
public class LcBannerController extends BaseController
{
    @Autowired
    private ILcBannerService lcBannerService;

    /**
     * 查询海报列表
     */
    @PreAuthorize("@ss.hasPermi('lclook:banner:list')")
    @GetMapping("/list")
    public TableDataInfo list(LcBanner lcBanner)
    {
        startPage();
        List<LcBanner> list = lcBannerService.selectLcBannerList(lcBanner);
        return getDataTable(list);
    }

    /**
     * 导出海报列表
     */
    @PreAuthorize("@ss.hasPermi('lclook:banner:export')")
    @Log(title = "海报", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LcBanner lcBanner)
    {
        List<LcBanner> list = lcBannerService.selectLcBannerList(lcBanner);
        ExcelUtil<LcBanner> util = new ExcelUtil<LcBanner>(LcBanner.class);
        return util.exportExcel(list, "海报数据");
    }

    /**
     * 获取海报详细信息
     */
    @PreAuthorize("@ss.hasPermi('lclook:banner:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(lcBannerService.selectLcBannerById(id));
    }

    /**
     * 新增海报
     */
    @PreAuthorize("@ss.hasPermi('lclook:banner:add')")
    @Log(title = "海报", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LcBanner lcBanner)
    {
        return toAjax(lcBannerService.insertLcBanner(lcBanner));
    }

    /**
     * 修改海报
     */
    @PreAuthorize("@ss.hasPermi('lclook:banner:edit')")
    @Log(title = "海报", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LcBanner lcBanner)
    {
        return toAjax(lcBannerService.updateLcBanner(lcBanner));
    }

    /**
     * 删除海报
     */
    @PreAuthorize("@ss.hasPermi('lclook:banner:remove')")
    @Log(title = "海报", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(lcBannerService.deleteLcBannerByIds(ids));
    }
}
